package com.mini.gateway.core.modules.log.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.mini.gateway.core.modules.log.entity.ApiLog;
import lombok.Data;

import java.time.LocalDateTime;

/**
 * ApiLogDTO
 *
 */
@Data
public class ApiLogDTO {

    /** routeId */
    private String routeId;

    /** 方法 */
    private String method;

    /** uri */
    private String uri;

    /** ip */
    private String host;

    /** 端口 */
    private Integer port;
    /** 响应code */
    private Integer responseCode;

    private String remoteHost;

    private Long elapsedTime;
    /** '调用时间' */
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss SSS")
    private LocalDateTime startTime;

    public ApiLogDTO(ApiLog log) {
        this.routeId = log.getRouteId();
        this.method = log.getMethod();
        this.uri = log.getUri();
        this.host = log.getHost();
        this.port = log.getPort();
        this.responseCode = log.getResponseCode();
        this.remoteHost = log.getRemoteHost();
        this.elapsedTime = log.getElapsedTime();
        this.startTime = log.getStartTime();
    }
}
